/*
 * @Author: Otway
 * @Date: 2019-01-09 11:16:08
 * @LastEditors: Otway
 * @LastEditTime: 2019-08-30 18:50:09
 * @copyright: h-visions
 */
import React, { PureComponent } from 'react';
import {
  Row,
  Col,
  Form,
  Input,
  DatePicker,
  Upload,
  Button,
  Icon
} from 'antd';
import moment from 'moment'
import TextArea from 'antd/lib/input/TextArea';
const FormItem = Form.Item;
const formItemLayout = {
  // 抽屉里面Form。二列的布局比例
  labelCol: {
    span: 6
  },
  wrapperCol: {
    span: 18
  }
};

class DetailsForm extends PureComponent {
  state = {
    fileList: []
  }
  render() {
    const {
      formData,
      form: { getFieldDecorator },
      saveFileList,
      formType
    } = this.props;
    console.log('传递数据是什么', formData);
    const { fileList } = this.state;
    const accept = {
      accept: '.png,.jpg,.jpge,.pdf'
    }
    const propsFile = {
      ...accept,
      onRemove: (file) => {
        this.setState((state) => {
          const index = state.fileList.indexOf(file);
          const newFileList = state.fileList.slice();
          newFileList.splice(index, 1);
          saveFileList(0, newFileList)
          return {
            fileList: newFileList,
          };
        });
      },
      beforeUpload: (file) => {
        saveFileList(0, [...fileList, file])
        this.setState(state => ({
          fileList: [...state.fileList, file],
        }));
        return false;
      },
      fileList,
    };
    return (
      <Form style={{ marginTop: '20px' }} >
        <Row style={{ display: formType !== 2 ? 'block' : 'none' }}>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'顺序号'}>
              {getFieldDecorator('orderNo', {
                initialValue: formData.orderNo || null
              })(<Input disabled />)}
            </FormItem>
          </Col>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'出机日期'}>
              {getFieldDecorator('firstOutputTime', {
                initialValue: formData.firstOutputTime ? moment(formData.firstOutputTime) : null,
              })(<DatePicker style={{ width: '100%' }} disabled />)}
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'批号'}>
              {getFieldDecorator('batchNo', {
                initialValue: formData.batchNo || '',
              })(<Input disabled />)}
            </FormItem>
          </Col>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'交机日期'}>
              {getFieldDecorator('firstDeliveryTime', {
                initialValue: formData.firstDeliveryTime ? moment(formData.firstDeliveryTime) : null,
              })(<DatePicker style={{ width: '100%' }} disabled />)}
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'客户名称'}>
              {getFieldDecorator('customerName', {
                initialValue: formData.customerName || '',
              })(<Input disabled />)}
            </FormItem>
          </Col>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'特供内容'}>
              {getFieldDecorator('specialContent', {
                initialValue: formData.specialContent || '',
              })(<TextArea disabled />)}
            </FormItem>
          </Col>
          {/* <Col span={12}>
            <FormItem {...formItemLayout} label={'机型'}>
              {getFieldDecorator('model', {
                initialValue: formData.model || '',
              })(<Input disabled />)}
            </FormItem>
          </Col> */}

        </Row>
        <Row>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'备注内容'}>
              {getFieldDecorator('remarks', {
                initialValue: formData.remarks || '',
              })(<TextArea disabled />)}
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'监制'}>
              <span>{formData.createPerson}</span>
            </FormItem>
          </Col>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'审批'}>
              <span>{formData.examinePerson}</span>
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'日期'}>
              <span>{formData.createTime}</span>
            </FormItem>
          </Col>
          <Col span={12}>
            <FormItem {...formItemLayout} label={'审批日期'}>
              <span>{formData.examineTime}</span>
            </FormItem>
          </Col>
        </Row>
      </Form>
    );
  }
}

export default Form.create()(DetailsForm);
